<template>
    <el-dialog custom-class="form-dialog" :title="title" :visible.sync="dialogVisible" :close-on-click-modal="false" width="800px" v-loading="loading"
        :before-close="handleClose">
        <!-- 表单内容 -->
        <div class="form-dialog-content-box">
            <el-form :model="form" label-width="100px" :rules="rules" ref="ruleForm" :size="size">
                <el-form-item label="物料分类：" prop="materialCategoryId">
                    <zll-select v-model="form.materialCategoryId" api="/api//materialCategorys/list" labelKey="name" filterable
                        placeholder="请选择" :size="size"></zll-select>
                </el-form-item>
                <el-form-item label="物料编号：" prop="code">
                    <el-input v-model="form.code" :size="size"></el-input>
                </el-form-item>
                <el-form-item label="物料名称：" prop="name" style="width: 100%;">
                    <el-input v-model="form.name" :size="size"></el-input>
                </el-form-item>
                <el-form-item label="规格：" prop="specifications" style="width: 100%;">
                    <el-input v-model="form.specifications" :size="size"></el-input>
                </el-form-item>
                <el-form-item label="单位：" prop="unit">
                    <el-input v-model="form.unit" :size="size"></el-input>
                </el-form-item>
                <el-form-item label="状态：" prop="status">
                    <el-switch v-model.number="form.status" :active-value="1" :inactive-value="0"></el-switch>
                </el-form-item>
                <el-form-item label="备注：" prop="remarks" style="width: 100%;">
                    <el-input v-model="form.remarks" :size="size" type="textarea" :rows="3"></el-input>
                </el-form-item>
            </el-form>
        </div>
        <!-- 提交区域 -->
        <span slot="footer" class="dialog-footer">
            <el-button @click="handleCancelBtn" :size="size">取 消</el-button>
            <el-button type="primary" @click="handleSubmitBtn" :size="size">确 定</el-button>
        </span>
    </el-dialog>
</template>

<script>
//引入混入逻辑
import mixin from '@/mixins/form'
export default {
    name: "formDialog",
    mixins: [mixin],
    props: {
        title: {
            type: String,
            default: "新增"
        }
    },
    data() {
        return {
            loading: false,//页面加载状态

            dialogVisible: false,//对话框展示状态
            form: {
                id: "",
                materialCategoryId: "",
                name: "",
                code: "",
                specifications: "",
                unit: "",
                status: 1,
                remarks: ""
            },//表单数据

            rules: {
                materialCategoryId: [
                    { required: true, message: '请选择物料分类', trigger: 'change' },
                ],
                name: [
                    { required: true, message: '请输入物料名称', trigger: 'blur' },
                ],
                code: [
                    { required: true, message: '请输入物料编号', trigger: 'blur' },
                ],
                specifications: [
                    { required: true, message: '请输入规格', trigger: 'blur' },
                ],
                unit: [
                    { required: true, message: '请输入单位', trigger: 'blur' },
                ],
            },//表单验证规则
        }
    },
    methods: {
        
    }
}
</script>

<style scoped lang="scss">
.form-dialog-content-box {
    ::v-deep .el-form{
        display: flex;
        flex-wrap: wrap;
        .el-form-item{
            width: 50%;
            .el-select{
                display: block;
            }
        }
    }
}
</style>